using System;
using System.Web.UI;
using Domain.Entities;
using UserInterface.Misc;

namespace UserInterface.UserControls
{
    public partial class UploadedAttachment : UserControl
    {
        private Attachment attachment;

        public Attachment Attachment
        {
            get { return attachment; }
            set { attachment = value; }
        }

        protected void Page_PreRender(object sender, EventArgs e)
        {
            FileNameLiteral.Text = String.Format(
                (string)GetLocalResourceObject("FileNameFormat"),
                attachment.LocalId,
                attachment.FileName,
                attachment.FileLength
            );
            DownloadLink.NavigateUrl = "~/" + UITools.getAttachmentDownloadURL(attachment);
            DownloadLink.ToolTip = String.Format(
                (string)GetLocalResourceObject("DownloadLinkTitle"),
                attachment.FileName
            );
        }

        public event EventHandler Remove;

        protected void RemoveButton_Click(object sender, EventArgs e)
        {
            Remove(this, EventArgs.Empty);
        }
    }
}